@extends('layouts.master3')
@section('title')
{{"千里码-人才服务-后台"}}
@stop

@section('style')
<style>
    .table thead tr th, .table tbody tr, .table tbody tr th, .contain h1 {
        text-align: center;
    }
    .table a{
        display: inline-block;
        margin-left:10px;
    }
    .table button {
        display: block;
        border:none;
        background: initial;
        margin: 0 auto;
        color: #337ab7;
    }
    .table .operate[disabled]{
        color:gray;
    }
    .table-bordered>tbody>tr>td{
        vertical-align: middle;
    }
    .form-group {
        text-align: left;
    }
    .form-group label {
        width:100px;
        vertical-align: top;
        margin-top: 10px;
    }
    .modal form{
        display: none;
    }
    .modal form button {
        display: block;
        margin:0 auto;
    }
    .form-control {
        display: inline-block;
        width: 70%;
    }
</style>
@stop

@section('content')

    <!--模板内容开始-->
<div class="contain">
    <input type="hidden" id="token"  value="{{csrf_token()}}" />
    <table class="table table-bordered table-hover">
        <thead style="background: #DDDDDD;">
        <tr>
            <th>候选人</th>
            <th>邀请时间</th>
            <th>公司</th>
            <th>职位</th>
            <th>薪资待遇</th>
            <th>状态</th>
            <th>其他</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
		<?php foreach($data as $da){?>
        <tr>
            <td>{{$da['name']}}</td>
            <td>{{$da['create_at']}}</td>
            <td>{{$da['company_name']}}</td>
            <td>{{$da['title']}}</td>
            <td>{{$da['salary']}}</td>
            <td>{{$da['statusstr']}}</td>
            <td><a target="_blank" href="http://www.qlcoder.com/talent?userid={{$da["userid2"]}}">查看简历</a></td>
            <td>
                <?php if($da['status']==-2) echo '<button class="operate" data-target="#send-invite" data-id="'.$da["invitid"].'" data-userid="'.$da["userid2"].'">发送面试邀请</button>';?>
                <?php if($da['status']==210) echo '<button class="operate" data-target="#send-invite-time" data-id="'.$da["invitid"].'">发送面试时间地点</button>';?>
                <?php if($da['status']==211) echo '<button class="operate" data-target="#update-invite-time" data-id="'.$da["invitid"].'">修改面试时间地点</button>';?>
                <?php if($da['status']==214) echo '<button class="operate" data-target="#send-offer" data-id="'.$da["invitid"].'">发送offer</button>';?>
                <?php if($da['status']==214) echo '<button class="operate" data-target="#not-pass" data-id="'.$da["invitid"].'">面试未通过</button>';?>
                <?php if($da['status']==211) echo '<form method="post" action="/talent/admin/end_invit"><input type="hidden" name="_token" value="'.csrf_token().'" /><input type="hidden" name="invitid" value="'.$da["invitid"].'" /> <button data-target="#not-pass" data-id="5">面试结束</button></form>';?>
            </td>
			</tr>
<?php }
?>
        </tbody>
    </table>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">操作</h4>
                </div>
                <div class="modal-body">
                    <!--发送面试邀请 S-->
                    <form method="post" action="/talent/admin/send_invit" id="send-invite">
						<input type="hidden" name="_token" value="{{csrf_token()}}" />
                        <div class="form-group">
							<input type="hidden" name="invitid" value="">
							<input type="hidden" name="userid" value="">
                            <label>候选人:</label>
                            <input type="text" class="form-control houxuan" placeholder="候选人" readonly />
                        </div>
                        <div class="form-group">
                            <label>公司:</label>
                            <input class="form-control search-input" style="width:30%;" />
                            <a href="javascript:;" class="company-search btn btn-default" style="display:inline-block;">搜索</a>
                            <select name="companyid" class="form-control" style="width:29%;">
                                <option value=""></option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>职位名称:</label>
                            <input type="text" class="form-control" required placeholder="职位名称" name="title" />
                        </div>
                        <div class="form-group">
                            <label>薪资:</label>
                            <input type="text" class="form-control" required placeholder="薪资" name="salary" />
                        </div>
                        <div class="form-group">
                            <label>职位描述:</label>
                            <input type="text" class="form-control" required placeholder="职位描述" name="desc" />
                        </div>
						<div class="_tip" style="color:red;text-align:center;display:none;">还有未填项</div>
                        <button type="submit" class="btn btn-default">确认</button>
                    </form>
                    <!--发送面试邀请 E-->
                    <!--发送面试时间地点 S-->
                    <form method="post" action="/talent/admin/send_invittime" id="send-invite-time">
						<input type="hidden" name="_token" value="{{csrf_token()}}" />
                        <div class="form-group">
							<input type="hidden" name="invitid" value="">
                            <label>候选人:</label>
                            <input type="text" class="form-control houxuan" placeholder="候选人" value="" readonly />
                        </div>
                        <div class="form-group">
                            <label>面试时间:</label>
                            <input type="text" class="form-control" required placeholder="面试时间" name="invittime" />
                        </div>
                        <div class="form-group">
                            <label>面试地点:</label>
                            <textarea class="form-control" required placeholder="面试地点" name="invitaddress"></textarea>
                        </div>
                        <div class="form-group">
                            <label>补充:</label>
                            <textarea class="form-control" placeholder="补充" name="remark"></textarea>
                        </div>
                        <button type="submit" class="btn btn-default">确认</button>
                    </form>
                    <!--发送面试时间地点 E-->
                    <!--修改面试时间地点 S-->
                    <form method="post" action="/talent/admin/send_invittime" id="update-invite-time">
						<input type="hidden" name="_token" value="{{csrf_token()}}" />
                        <div class="form-group">
							<input type="hidden" name="invitid" value="">
                            <label>候选人:</label>
                            <input type="text" required class="form-control houxuan" placeholder="候选人" value="" readonly />
                        </div>
                        <div class="form-group">
                            <label>修改面试时间:</label>
                            <input type="text" required class="form-control" placeholder="修改面试时间" name="invittime" />
                        </div>
                        <div class="form-group">
                            <label>修改面试地点:</label>
                            <textarea class="form-control" required placeholder="修改面试地点" name="invitaddress"></textarea>
                        </div>
                        <div class="form-group">
                            <label>补充:</label>
                            <textarea class="form-control" placeholder="补充" name="remark"></textarea>
                        </div>
                        <button type="submit" class="btn btn-default">确认</button>
                    </form>
                    <!--修改面试时间地点 E-->
                    <!--发送offer S-->
                    <form method="post" action="/talent/admin/send_offer" id="send-offer">
                        <input type="hidden" name="_token" value="{{csrf_token()}}" />
						<div class="form-group">
							<input type="hidden" name="invitid" value="">
                            <label>候选人:</label>
                            <input type="text"  class="form-control houxuan" placeholder="候选人" readonly />
                        </div>
                        <div class="form-group">
                            <label>岗位:</label>
                            <input type="text" required class="form-control" placeholder="岗位" name="final_title" />
                        </div>
                        <div class="form-group">
                            <label>薪资:</label>
                            <input type="text" required class="form-control" placeholder="薪资" name="final_salary" />
                        </div>
                        <div class="form-group">
                            <label>补充:</label>
                            <input type="text" class="form-control" placeholder="补充" name="remark" />
                        </div>
                        <button type="submit" class="btn btn-default">确认</button>
                    </form>
                    <!--发送offer E-->
                    <form method="post" action="/talent/admin/notpass_offer" id="not-pass">
						<input type="hidden" name="_token" value="{{csrf_token()}}" />
                        <div class="form-group">
							<input type="hidden" name="invitid" value="">
                            <label>面试未通过理由</label>
                            <input type="text" required class="form-control" placeholder="面试未通过理由" name="remark"/>
                        </div>
                        <button type="submit" class="btn btn-default">确认</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!--模板内容结束-->

@section('js')
<script>
    (function($){
        $(".operate").click(function () {
            var target = $(this).attr("data-target"),
                id     = $(this).attr("data-id"),
				opearte= $(this).html(),
				userid = $(this).attr("data-userid"),
				name   = $(this).parents("tr").find("td").first().html();
			$(".houxuan").val(name);
            $("#myModalLabel").html(opearte);
            $(".modal form").hide();
            $(".modal "+target).show().find("input[name='invitid']").val(id);
            $(".modal "+target).show().find("input[name='userid']").val(userid);
            $("#myModal").modal('show');
        });
		$("#send-invite button").click(function(e){
			e.preventDefault();
			if($("select").val()=="" || $("input[name='title']").val()=="" || $("input[name='salary']").val() == "" || $("input[name='desc']").val()=="" ){
				$("._tip").show();
				return;
			}else{
				$("#send-invite").submit();
			}
		})
        $(".company-search").click(function(){
            var search = $(".search-input").val();
            $.ajax({
                url:'/talent/search_com',
                type:"post",
                dataType:"json",
                data:{
                    _token:$("#token").val(),
                    name:search
                },
                success:function(res){
                    var html = "";
                    html = res.data.map(function(v){
                        return ('<option value="'+v.id+'">'+v.name+'</option>');
                    }).join("");
                    $("select").html(html);
                }
            })
        })
    })(jQuery);
</script>
@endsection
@endsection



